package com.yvon.maple.msg.parser;

import java.util.List;
import java.util.Map;

/**
 * 解析器
 *
 * @author : Yvon
 * @since : 2021-10-28
 */
public interface MsgParser<T> {

    /**
     * The constant VARIABLE.
     */
    String VARIABLE = "variable";

    /**
     * variable like 0, 1, 2, 3, 4.
     */
    String PATTERN = "${"+ VARIABLE +"}";


    /**
     * Parse string.
     *
     * @param content the content
     * @param params  the params
     * @return String
     * @author : Yvon / 2021-10-28
     */
    String parse(String content, List<T> params);

    /**
     * Parse string.
     *
     * @param content the content
     * @param params  the params
     * @return String
     * @author : Yvon / 2021-10-28
     */
    String parse(String content, T... params);



    /**
     * Parse string.
     *
     * @param content the content
     * @param params  the params
     * @return String
     * @author : Yvon / 2021-10-28
     */
    String parse(String content, Map<String, String> map);


    /**
     * Parse string.
     *
     * @param content the content
     * @param pattern the pattern
     * @param value   the value
     * @return String
     * @author : Yvon / 2021-10-28
     */
    default String replace(String content, String pattern, String value) {
        return content.replace(pattern, value);
    }
}
